﻿<common:LayoutAwarePage
    x:Name="pageRoot"
    x:Class="Finance.GroupedItemsPage"
    DataContext="{Binding DefaultViewModel, RelativeSource={RelativeSource Self}}"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:Finance"
    xmlns:data="using:Finance.Data"
    xmlns:common="using:Finance.Common"
    xmlns:tiles="using:Finance.VariableTemplate"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">


	 <Page.TopAppBar>
        <AppBar x:Name="TopApp" Padding="10,0,10,0" MinHeight="110" Background="#FF0F0F0F" BorderBrush="#FF0F0F0F">
            <Grid Height="100" Margin="0">
                <StackPanel Margin="0" Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Left">
                    <Button x:Name="btnHome" Tag="Home" HorizontalAlignment="Right" BorderBrush="{x:Null}" BorderThickness="0" FontWeight="Normal" VerticalAlignment="Center" Padding="0" Style="{StaticResource TopAppbarBtnStyle}"  >
                        <Grid HorizontalAlignment="Center" VerticalAlignment="Center" Height="97" Margin="0" Width="97" Background="#FF292929">
                            <Image Source="Assets/AppBar/TopAppBarIcon1.png" Margin="0"/>
                        </Grid>
                    </Button>
                    <Button x:Name="btnMarketWatch" Tag="Market Watch" HorizontalAlignment="Right" BorderBrush="{x:Null}" BorderThickness="0" FontWeight="Normal" VerticalAlignment="Center" Padding="0" Style="{StaticResource TopAppbarBtnStyle}" Margin="10,0,0,0" Tapped="btnMarketWatch_Tapped_1"  >
                    	<Grid HorizontalAlignment="Center" VerticalAlignment="Center" Height="97" Margin="0" Width="97" Background="#FF292929">
                    		<Image Source="Assets/AppBar/TopAppBarIcon2.png" Margin="0"/>
                    	</Grid>
                    </Button>
                    <Button x:Name="btnMarketNews" Tag="Market News" HorizontalAlignment="Right" BorderBrush="{x:Null}" BorderThickness="0" FontWeight="Normal" VerticalAlignment="Center" Padding="0" Style="{StaticResource TopAppbarBtnStyle}" Margin="10,0,0,0" Tapped="btnMarketNews_Tapped_1" >
                    	<Grid HorizontalAlignment="Center" VerticalAlignment="Center" Height="97" Margin="0" Width="97" Background="#FF292929">
                    		<Image Source="Assets/AppBar/TopAppBarIcon3.png" Margin="0"/>
                    	</Grid>
                    </Button>
                    <Button x:Name="btnResearch" Tag="Research" HorizontalAlignment="Right" BorderBrush="{x:Null}" BorderThickness="0" FontWeight="Normal" VerticalAlignment="Center" Padding="0" Style="{StaticResource TopAppbarBtnStyle}" Margin="10,0,0,0" Tapped="btnResearch_Tapped_1" >
                    	<Grid HorizontalAlignment="Center" VerticalAlignment="Center" Height="97" Margin="0" Width="97" Background="#FF292929">
                    		<Image Source="Assets/AppBar/TopAppBarIcon4.png" Margin="0"/>
                    	</Grid>
                    </Button>
                    <Button x:Name="btnMyScrips" Tag="My Scrips" HorizontalAlignment="Right" BorderBrush="{x:Null}" BorderThickness="0" FontWeight="Normal" VerticalAlignment="Center" Padding="0" Style="{StaticResource TopAppbarBtnStyle}" Margin="10,0,0,0" Tapped="btnMyScrips_Tapped_1" >
                    	<Grid HorizontalAlignment="Center" VerticalAlignment="Center" Height="97" Margin="0" Width="97" Background="#FF292929">
                    		<Image Source="Assets/AppBar/TopAppBarIcon5.png" Margin="0"/>
                    	</Grid>
                    </Button>
                    <Button x:Name="btnGetQuote" Tag="Get Quote" HorizontalAlignment="Right" BorderBrush="{x:Null}" BorderThickness="0" FontWeight="Normal" VerticalAlignment="Center" Padding="0" Style="{StaticResource TopAppbarBtnStyle}" Margin="10,0,0,0" Tapped="btnGetQuote_Tapped_1" >
                    	<Grid HorizontalAlignment="Center" VerticalAlignment="Center" Height="97" Margin="0" Width="97" Background="#FF292929">
                    		<Image Source="Assets/AppBar/TopAppBarIcon6.png" Margin="0"/>
                    	</Grid>
                    </Button>
                </StackPanel>
            </Grid>
        </AppBar>
    </Page.TopAppBar>

	<Page.BottomAppBar>
        <AppBar x:Name="BottamApp" Padding="10,0,10,0" MinHeight="90" Background="#FF0F0F0F" BorderBrush="#FF0F0F0F">
            <Grid Margin="20,10,0,10">
                <StackPanel Margin="0" Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Left">
                    <Button x:Name="btnAdd" HorizontalAlignment="Right" BorderBrush="{x:Null}" BorderThickness="0" FontWeight="Normal"  VerticalAlignment="Stretch" Padding="0" Style="{StaticResource TopAppbarBtnStyle}" Margin="10,0" >
                        <Grid HorizontalAlignment="Center" VerticalAlignment="Center" Height="73" Margin="0">
                        	<Grid.RowDefinitions>
                        		<RowDefinition Height="75"/>
                        	</Grid.RowDefinitions>
                            <Image HorizontalAlignment="Center" VerticalAlignment="Center" Source="Assets/AppBar/BtmAppBarBtn1.png" Margin="0" Height="73"/>
                        </Grid>
                    </Button>
                    <Button x:Name="btnRemove" HorizontalAlignment="Right" BorderBrush="{x:Null}" BorderThickness="0" FontWeight="Normal"  VerticalAlignment="Stretch" Padding="0" Style="{StaticResource TopAppbarBtnStyle}" Margin="10,0"  >
                    	<Grid HorizontalAlignment="Center" VerticalAlignment="Center" Height="73" Margin="0">
                    		<Grid.RowDefinitions>
                    			<RowDefinition Height="75"/>
                    		</Grid.RowDefinitions>
                    		<Image HorizontalAlignment="Center" VerticalAlignment="Center" Source="Assets/AppBar/BtmAppBarBtn2.png" Margin="0" Height="73"/>
                    	</Grid>
                    </Button>

                </StackPanel>
            </Grid>
        </AppBar>
    </Page.BottomAppBar>

    <Page.Resources>

        <!--
            Collection of grouped items displayed by this page, bound to a subset
            of the complete item list because items in groups cannot be virtualized
        -->
        <CollectionViewSource
            x:Name="groupedItemsViewSource"
            Source="{Binding Groups}"
            IsSourceGrouped="true"
            ItemsPath="Items"
            d:Source="{Binding AllGroups, Source={d:DesignInstance Type=data:SampleDataSource, IsDesignTimeCreatable=True}}"/>

        <tiles:VariableTiles x:Key="MyTemplateSelectorObj" 
                             
                             NormalTileTemplate="{StaticResource NormalTileItemTemplate}"
                             NewsTemplate="{StaticResource NewsItemTemplate}">


        </tiles:VariableTiles>
    </Page.Resources>

    <!--
        This grid acts as a root panel for the page that defines two rows:
        * Row 0 contains the back button and page title
        * Row 1 contains the rest of the page layout
    -->
    <Grid Style="{StaticResource LayoutRootStyle}">
        <Grid.RowDefinitions>
            <RowDefinition Height="140"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!-- Horizontal scrolling grid used in most view states -->

        <!-- Vertical scrolling list only used when snapped -->
        <Image Grid.Row="1" Source="Assets/HubPage/Bg.jpg" Stretch="UniformToFill"/>

        <!-- Vertical scrolling list only used when snapped -->
        <ListView
            x:Name="itemListView"
            AutomationProperties.AutomationId="ItemListView"
            AutomationProperties.Name="Grouped Items"
            Grid.Row="1"
            Visibility="Collapsed"
            Margin="0,-10,0,0"
            Padding="10,0,0,60"
            ItemsSource="{Binding Source={StaticResource groupedItemsViewSource}}"
            ItemTemplate="{StaticResource SnapedNormalTileItemTemplate}"
            SelectionMode="None"
            IsSwipeEnabled="false"
            IsItemClickEnabled="True"
            ItemClick="ItemView_ItemClick">

            <ListView.GroupStyle>
                <GroupStyle>
                    <GroupStyle.HeaderTemplate>
                        <DataTemplate>
                            <Grid Margin="7,7,0,0">
                                <Button
                                    AutomationProperties.Name="Group Title"
                                    Click="Header_Click"
                                    Style="{StaticResource TextPrimaryButtonStyle}">
                                    <StackPanel Orientation="Horizontal">
                                        <TextBlock Text="{Binding Title}" Margin="3,-7,10,10" Style="{StaticResource GroupHeaderTextStyle}" />
                                        <TextBlock Text="{StaticResource ChevronGlyph}" FontFamily="Segoe UI Symbol" Margin="0,-7,0,10" Style="{StaticResource GroupHeaderTextStyle}"/>
                                    </StackPanel>
                                </Button>
                            </Grid>
                        </DataTemplate>
                    </GroupStyle.HeaderTemplate>
                </GroupStyle>
            </ListView.GroupStyle>
        </ListView>

        <!-- Back button and page title -->
        <ScrollViewer x:Name="scrollViewer" Grid.RowSpan="2" Style="{StaticResource HorizontalScrollViewerStyle}">
        	<Grid>
        		<Grid.ColumnDefinitions>
        			<ColumnDefinition Width="665"/>
        			<ColumnDefinition Width="*"/>
        		</Grid.ColumnDefinitions>
                <!--<GridView
        			x:Name="itemGridView"
        			AutomationProperties.AutomationId="ItemGridView"
        			AutomationProperties.Name="Grouped Items"
        			Padding="116,137,40,46"
        			ItemsSource="{Binding Source={StaticResource groupedItemsViewSource}}"
        			ItemTemplate="{StaticResource Standard250x250ItemTemplate}"
        			SelectionMode="None"
        			IsSwipeEnabled="false"
        			IsItemClickEnabled="True"
        			ItemClick="ItemView_ItemClick" Margin="0" Grid.Column="1">

        			<GridView.ItemsPanel>
        				<ItemsPanelTemplate>                        
        					<VirtualizingStackPanel Orientation="Horizontal"/>
        				</ItemsPanelTemplate>
        			</GridView.ItemsPanel>
        			<GridView.GroupStyle>
        				<GroupStyle>
        					<GroupStyle.HeaderTemplate>
        						<DataTemplate>
        							<Grid Margin="1,0,0,6">
        								<Button
        									AutomationProperties.Name="Group Title"
        									Click="Header_Click"
        									Style="{StaticResource TextPrimaryButtonStyle}" >
        									<StackPanel Orientation="Horizontal">
        										<TextBlock Text="{Binding Title}" Margin="3,-7,10,10" Style="{StaticResource GroupHeaderTextStyle}" />
        										<TextBlock Text="{StaticResource ChevronGlyph}" FontFamily="Segoe UI Symbol" Margin="0,-7,0,10" Style="{StaticResource GroupHeaderTextStyle}"/>
        									</StackPanel>
        								</Button>
        							</Grid>
        						</DataTemplate>
        					</GroupStyle.HeaderTemplate>
        					<GroupStyle.Panel>
        						<ItemsPanelTemplate>
        							<VariableSizedWrapGrid Orientation="Vertical" Margin="0,0,80,0"/>
        						</ItemsPanelTemplate>
        					</GroupStyle.Panel>
        				</GroupStyle>
        			</GridView.GroupStyle>
        		</GridView>-->
        		<Grid Background="#FF101010">
        			<Grid.RowDefinitions>
        				<RowDefinition Height="140"/>
        				<RowDefinition Height="*"/>
        			</Grid.RowDefinitions>
        			<Grid Grid.Row="1" Margin="120,0,0,0">
        				<Grid.RowDefinitions>
        					<RowDefinition Height="60"/>
        					<RowDefinition Height="235"/>
        					<RowDefinition Height="35"/>
        					<RowDefinition Height="60"/>
        					<RowDefinition Height="235"/>
        					<RowDefinition Height="*"/>
        				</Grid.RowDefinitions>
        				<StackPanel Orientation="Horizontal">
        					<StackPanel Margin="0,0,10,0">
        						<TextBlock TextWrapping="Wrap" Text="NIFTY" Foreground="#FFFFD200" FontFamily="Segoe UI" FontSize="24" FontWeight="Light"/>
        						<TextBlock TextWrapping="Wrap" Text="17 Aug (11.00)" FontFamily="Segoe UI" Foreground="#FFFFD200" FontSize="12" FontWeight="SemiBold"/>
        					</StackPanel>
        					<TextBlock TextWrapping="Wrap" Text="5129.75" VerticalAlignment="Center" FontFamily="Segoe UI" FontSize="48" FontWeight="Light" Margin="10,0"/>
        					<Image Width="47" Height="48" Source="Assets/HubPage/High.png" Margin="10,0"/>
        					<StackPanel VerticalAlignment="Center" Margin="10,0">
        						<TextBlock TextWrapping="Wrap" Text="+29.90" FontFamily="Segoe UI" Foreground="White" FontSize="14.667" FontWeight="SemiBold" Margin="0,0,0,5"/>
        						<TextBlock TextWrapping="Wrap" Text="+0.59%" FontFamily="Segoe UI" Foreground="White" FontSize="14.667" FontWeight="SemiBold" Margin="0"/>
        					</StackPanel>
        				</StackPanel>
        				<Image Grid.Row="1" Source="Assets/HubPage/Chart.png" HorizontalAlignment="Left"/>
        				<StackPanel Orientation="Horizontal" Grid.Row="3">
        					<StackPanel Margin="0,0,10,0">
        						<TextBlock TextWrapping="Wrap" Text="Sensex" Foreground="#FFFFD200" FontFamily="Segoe UI" FontSize="24" FontWeight="Light"/>
        						<TextBlock TextWrapping="Wrap" Text="17 Aug (04.30)" FontFamily="Segoe UI" Foreground="#FFFFD200" FontSize="12" FontWeight="SemiBold"/>
        					</StackPanel>
        					<TextBlock TextWrapping="Wrap" Text="22535.98" VerticalAlignment="Center" FontFamily="Segoe UI" FontSize="48" FontWeight="Light" Margin="10,0"/>
        					<Image Width="47" Height="48" Source="Assets/HubPage/Low.png" Margin="10,0"/>
        					<StackPanel VerticalAlignment="Center" Margin="10,0">
        						<TextBlock TextWrapping="Wrap" Text="+29.90" FontFamily="Segoe UI" Foreground="White" FontSize="14.667" FontWeight="SemiBold" Margin="0,0,0,5"/>
        						<TextBlock TextWrapping="Wrap" Text="+0.59%" FontFamily="Segoe UI" Foreground="White" FontSize="14.667" FontWeight="SemiBold" Margin="0"/>
        					</StackPanel>
        				</StackPanel>
        				<Image Grid.Row="4" Source="Assets/HubPage/Chart.png" HorizontalAlignment="Left"/>
        			</Grid>
                </Grid>

                <tiles:VariableTileControl
        			x:Name="itemGridView"
        			AutomationProperties.AutomationId="ItemGridView"
        			AutomationProperties.Name="Grouped Items"
        			Margin="0,140,0,0"
        			Padding="120,0,40,20"
        			ItemsSource="{Binding Source={StaticResource groupedItemsViewSource}}"
        			ItemTemplateSelector="{StaticResource MyTemplateSelectorObj}"
        			SelectionMode="None"
        			IsItemClickEnabled="True"
        			ItemClick="ItemView_ItemClick" HorizontalContentAlignment="Left" Grid.Column="1" Grid.Row="1">

                <tiles:VariableTileControl.ItemsPanel>
                    <ItemsPanelTemplate>
                        <VirtualizingStackPanel Orientation="Horizontal" Margin="1,0,60,0"/>
                    </ItemsPanelTemplate>
                </tiles:VariableTileControl.ItemsPanel>
                <tiles:VariableTileControl.GroupStyle>
                    <GroupStyle >
                        <GroupStyle.HeaderTemplate>
                            <DataTemplate>
                                <StackPanel Margin="1,0,0,6" Orientation="Horizontal">
                                    <Button
        									AutomationProperties.Name="Group Title"
        									Content="{Binding Title}"
        									Click="Header_Click"
        									Style="{StaticResource TextButtonStyle}" FontWeight="Light" Foreground="White" FontSize="26.667" Background="#FFD71921"/>
                                    <TextBlock Text="{StaticResource ChevronGlyph}" FontFamily="Segoe UI Symbol" Margin="10,0,0,10" Style="{StaticResource GroupHeaderTextStyle}" Foreground="White" Visibility="{Binding NvArrow}"/>
                                    <TextBlock x:Name="txtVideo" HorizontalAlignment="Right" TextWrapping="Wrap" Text="{Binding Sub}" VerticalAlignment="Bottom" Foreground="#FFC4261D" Margin="140,21,0,0" FontFamily="Segoe UI" FontSize="16" Visibility="Collapsed"/>
                                <TextBlock x:Name="txtPicture" HorizontalAlignment="Right" TextWrapping="Wrap" Text="{Binding Sub2}" VerticalAlignment="Bottom" Foreground="#FFC4261D" Margin="275,21,0,0" FontFamily="Segoe UI" FontSize="16" Visibility="Collapsed"/>
                                </StackPanel>
                            </DataTemplate>
                        </GroupStyle.HeaderTemplate>
                        <GroupStyle.Panel>
                            <ItemsPanelTemplate>
                                <VariableSizedWrapGrid ItemHeight="5" ItemWidth="5" MaximumRowsOrColumns="110" Orientation="Vertical" Margin="0,0,80,0"/>
                            </ItemsPanelTemplate>
                        </GroupStyle.Panel>
                    </GroupStyle>
                </tiles:VariableTileControl.GroupStyle>
            </tiles:VariableTileControl>
            </Grid>
        </ScrollViewer>
        <Grid>
            <Grid.ColumnDefinitions>
            	<ColumnDefinition Width="Auto"/>
            	<ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
        	<Button x:Name="backButton" Click="GoBack" IsEnabled="{Binding Frame.CanGoBack, ElementName=pageRoot}" Style="{StaticResource BackButtonStyle}"/>
        	<TextBlock x:Name="pageTitle" Text="{StaticResource AppName}" Grid.Column="1" IsHitTestVisible="false" Style="{StaticResource PageHeaderTextStyle}" Visibility="Collapsed"/>
        	<Image x:Name="image" HorizontalAlignment="Left" VerticalAlignment="Center" Width="212" Source="Assets/HubPage/Logo.png" Margin="0,20" Grid.Column="1"/>
        </Grid>

        <VisualStateManager.VisualStateGroups>

            <!-- Visual states reflect the application's view state -->
            <VisualStateGroup x:Name="ApplicationViewStates">
                <VisualState x:Name="FullScreenLandscape"/>
                <VisualState x:Name="Filled"/>

                <!-- The entire page respects the narrower 100-pixel margin convention for portrait -->
                <VisualState x:Name="FullScreenPortrait">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="backButton" Storyboard.TargetProperty="Style">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PortraitBackButtonStyle}"/>
                        </ObjectAnimationUsingKeyFrames>

                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="itemGridView" Storyboard.TargetProperty="Padding">
                            <DiscreteObjectKeyFrame KeyTime="0">
                            	<DiscreteObjectKeyFrame.Value>
                            		<Thickness>96,0,10,56</Thickness>
                            	</DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>

                <!--
                    The back button and title have different styles when snapped, and the list representation is substituted
                    for the grid displayed in all other view states
                -->
                <VisualState x:Name="Snapped">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="backButton" Storyboard.TargetProperty="Style">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource SnappedBackButtonStyle}"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="pageTitle" Storyboard.TargetProperty="Style">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource SnappedPageHeaderTextStyle}"/>
                        </ObjectAnimationUsingKeyFrames>

                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="itemListView" Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="itemGridView" Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="scrollViewer">
                        	<DiscreteObjectKeyFrame KeyTime="0">
                        		<DiscreteObjectKeyFrame.Value>
                        			<Visibility>Collapsed</Visibility>
                        		</DiscreteObjectKeyFrame.Value>
                        	</DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="TopApp">
                        	<DiscreteObjectKeyFrame KeyTime="0">
                        		<DiscreteObjectKeyFrame.Value>
                        			<Visibility>Collapsed</Visibility>
                        		</DiscreteObjectKeyFrame.Value>
                        	</DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="BottamApp">
                        	<DiscreteObjectKeyFrame KeyTime="0">
                        		<DiscreteObjectKeyFrame.Value>
                        			<Visibility>Collapsed</Visibility>
                        		</DiscreteObjectKeyFrame.Value>
                        	</DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>
    </Grid>
</common:LayoutAwarePage>
